package com.FH.organization.repair_type;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2017/4/28 0028.
 */
@Path("/RepairType")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class RepairTypeResource {

    @EJB
    RepairTypeDAO repairTypeDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getRepairTypeInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size) {

        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第0行开始查起
        }
        if (null == size || "".equals(size)) {
            size = "10";  //每页默认10条数据
        }
        return repairTypeDAO.getRepairTypeInfo(search, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addRepairTypeInfo(RepairTypePullDTO repairTypePullDTO){
        return repairTypeDAO.addRepairTypeInfo(repairTypePullDTO);
    }
}
